package controllers;

import beans.WebServiceBean;
import models.WebsiteInfo;
import play.mvc.Controller;
import play.mvc.With;

/**
 * Created by xieyicheng on 2015/3/4.
 */
@With(value = AdminCheck.class)
public class Infos extends Controller {
    public static void editorLink(int type) {
        WebsiteInfo info =WebsiteInfo.find("").first();
        if(info==null){
            info =  new WebsiteInfo();
            info.save();
        }
        String cont = "";
        if(type == 0)
        {
            cont=info.friend;
        }
        if(type == 1)
        {
            cont=info.aboutUs;
        }
        else if(type == 2)
        {
            cont= info.contactUs;
        }
        else if(type == 3)
        {
            cont= info.joinUs;
        }
        else if(type == 4)
        {
            cont=info.suggestion;
        }
        else if(type == 5)
        {
            cont= info.disclaimer;
        }
        render(type,cont);
    }
    /**
     *@author 李宇星
     *编辑网站信息
     *@param type 关于我们 = 1 联系我们 = 2 加入我们 = 3 意见反馈 = 4 免责声明 = 5
     **/
    public static void editWebsiteInfo(int type,String content)
    {
        WebsiteInfo info =WebsiteInfo.find("").first();
        if(info == null)
            info = new WebsiteInfo();
        if(type == 0)
        {
            info.friend = content;
            info.save();
        }
        if(type == 1)
        {
            info.aboutUs = content;
            info.save();
        }
        else if(type == 2)
        {
            info.contactUs = content;
            info.save();
        }
        else if(type == 3)
        {
            info.joinUs = content;
            info.save();
        }
        else if(type == 4)
        {
            info.suggestion = content;
            info.save();
        }
        else if(type == 5)
        {
            info.disclaimer = content;
            info.save();
        }
        else
        {

            SendSussess();
        }

        SendSussess();;
    }
    
    public static void SendSussess() {
        render();
    }
}
